# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=secure-delete
pkgver=1.b63d814
pkgrel=1
epoch=1
groups=('blackarch' 'blackarch-anti-forensic' 'blackarch-defensive')
pkgdesc='Secure file, disk, swap, memory erasure utilities.'
url='http://www.thc.org/'
conflicts=('srm')
license=('GPL')
arch=('x86_64' 'aarch64')
makedepends=('git')
source=("git+https://github.com/BlackArch/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i -e 's/mktemp/mkstemp/g' sfill.c
  sed -i -e "s/sswap smem sdel-mod.o/sswap smem/" -e '/test.*sdel-mod/d' \
    -e "s/^srm: /srm: sdel-lib.o /" -e "s/^sfill: /sfill: sdel-lib.o /" \
    -e "s/^sswap: /sswap: sdel-lib.o /" -e "s/^smem: /smem: sdel-lib.o /" \
    Makefile
}

build() {
  cd $pkgname

  make
}

package() {
  cd $pkgname

  make INSTALL_DIR="$pkgdir/usr/bin" \
    MAN_DIR="$pkgdir/usr/share/man" \
    DOC_DIR="$pkgdir/usr/share/doc/secure-delete" \
    install

  chmod a+r "$pkgdir/usr/bin"/*

  # Fix a conflict with community/smem.
  mv "$pkgdir/usr/bin/smem" "$pkgdir/usr/bin/smem-secure-delete"
  mv "$pkgdir/usr/share/man/man1/smem.1" \
    "$pkgdir/usr/share/man/man1/smem-secure-delete.1"
}

